<template>
  <div class="child-head">
    <div class="black" v-if="type" @click="go()">返回</div>
    <div class="name">{{ name }}</div>
  </div>
</template>

<script>
import { useRouter } from "vue-router";

export default {
  name: "child-head",
  props: {
    name: {
      type: String,
      default: "我是标题",
    },
    type: {
      type: Boolean,
      default: false,
    },
  },
  setup() {
    const router = useRouter();
    const go = () => {
      router.go(-1);
    };
    return {
      go,
    };
  },
};
</script>

<style scoped lang="scss">
.child-head {
  position: absolute;
  top: 0;
  left: 0;
  height: 0.6rem;
  width: 100%;
  background: rgba(215, 212, 212, 0.3);
  display: flex;
  justify-content: center;
  align-items: center;
  .black {
    position: absolute;
    left: 0.1rem;
    top: auto;
    font-size: 0.2rem;
    color: #2c3d50;
    text-align: center;
    font-weight: 600;
  }
  .name {
    font-size: 0.2rem;
    color: #2c3d50;
    text-align: center;
    font-weight: 600;
  }
}
</style>
